<%--
 *  @Author: JackYin 
 *  Date:    2011/1/22
 *
 *  Copyright (C) 2000 - 2001 Oval Technologies, Inc.
 *  All rights reserved.
 *
 *  This software is the confidential and proprietary information of Oval
 *  Technologies, Inc. ("Confidential Information").  You shall not
 *  disclose such Confidential Information and shall use it only in
 *  accordance with the terms of the license agreement you entered into
 *  with Oval.
--%>


<%@ include file="/inc/SessionTimeout.inc"%>
<%@ page language="java" %>
<%@ page import="java.util.*" %>
<%@ page import="com.oval.util.*" %>


<%@ page contentType = "text/html;charset=UTF-8" %>
<%@ taglib uri="/WEB-INF/PageFlow.tld" prefix="PageFlow" %>
<%@ taglib uri="/WEB-INF/custom.tld" prefix="custom" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="http://dcms.oval.com/page/dcms" prefix="dcms" %>
<%

  String strModuleName = "COM";
  String privilegeCode = "A02";
  String contextPath = request.getContextPath();
  HashMap userinfos = (HashMap)session.getAttribute("userinfo");
%>
<%@ include file="/inc/Security.inc" %>
<%@ include file="/inc/PageDefault.inc" %>
<html>
<head>
<title></title>
<%@ include file="/inc/CatchError.inc"%>
<PageFlow:CheckPageFlow pageName="p_zyldatauploadhead" />
<link rel="stylesheet" href="<%=contextPath %>/css/<%= strLanguageCode %>/main.css" type="text/css">
<script language="JavaScript" src="<%=contextPath %>/css/<%= strLanguageCode %>/script.js"></script>
<script language="JavaScript" src="<%=contextPath %>/js/ScriptLib.js"></script>
<%@ include file="/rpt/ReportURL.inc" %>
<%
HashMap deptinfo = new HashMap();
if(pageContext.getAttribute("deptinfo") != null){
        deptinfo = (HashMap)pageContext.getAttribute("deptinfo");
}
String strDeptCode = (deptinfo.get("deptcode")==null?"null":(String)(deptinfo.get("deptcode")));


%>
  <%Vector tabs = (Vector) pageContext.getAttribute("tabs");
  Integer countlog = (Integer) pageContext.getAttribute("countlog");
 // String countlog = countlog1.toString();
			if (tabs == null) tabs = new Vector();
			String strTableNum = new String("A01");
			String strTableName = new String("操作日志");
			int i = 0;
				%>
<style type="text/css">
	.bd{
	padding-top:0px;
	<--height:15px;-->
	}
	.sz{
	padding-left:10px;
	padding-right:5px;
	padding-top:15px;
	float:left;}
	
	div.RoundedCorner{background: #FDFAC5;margin-top:5px;} 
	b.rtop, b.rbottom{display:block;background: #FFFFFF} 
	b.rtop b, b.rbottom b{display:block;height: 1px;overflow: hidden; background: #FDFAC5} 
	b.r1{margin: 0 5px} 
	b.r2{margin: 0 3px} 
	b.r3{margin: 0 2px} 
	b.rtop b.r4, b.rbottom b.r4{margin: 0 1px;height: 2px} 
</style>
<script language="JavaScript">
function clicked(obj)
{
  var pk = parent.down.document.all.lendslipid;
  if(pk!=null&&pk.value=="")
  {
    alert('<%=message.getMessageDesc("SAVE_INFO_FIRST")%>');
	return false;
  }
  var url = "";
  if (obj.id == "A01")
	  url = "DataUploadLogView.jsp?<%= OvalTools.randomURL() %>";
  else if (obj.id == "A02")
	  url = "BusinessPurchaseView.jsp?<%= OvalTools.randomURL() %>";
	else if (obj.id == "A03")
	  url = "ABusinessSalesInvView.jsp?<%= OvalTools.randomURL() %>";
	  else if(obj.id == "A04")
		  url = "BBusinessSalesInvView.jsp?<%= OvalTools.randomURL() %>";
		  else if(obj.id == "A05")
			  url = "BusinessSellView.jsp?<%= OvalTools.randomURL() %>";
			  else if(obj.id == "A06")
				  url = "PharmacyPurchaseView.jsp?<%= OvalTools.randomURL() %>";
				  else if(obj.id == "A07")
					  url = "HospSalesInvView.jsp?<%= OvalTools.randomURL() %>";
					  else if(obj.id == "A08")
						  url = "HospPurchaseView.jsp?<%= OvalTools.randomURL() %>";
						  else if(obj.id == "A09")
							  url = "DoctorPrescriptionView.jsp?<%= OvalTools.randomURL() %>";
							  else if(obj.id == "A11")
								  url = "GenericdrugsPrescriptionView.jsp?<%= OvalTools.randomURL() %>";
							  
     parent.down.location.href=url;
     return true;
}
function page_exportX(){	
	var url;
	var deptcode = document.cform.deptcode.value;
	var id = document.cform.userid.value;
	if(deptcode == "YL010101"){
		url = "<%= reportURL %>/servlet/ExcecuteReport/hosiptaldatareport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
  	  
    }
	if(deptcode == "YL010102"){
		url = "<%= reportURL %>/servlet/ExcecuteReport/RetailDepartment.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
	}
    if(deptcode == "YL010103"){
  	  if(confirm("点击“确定”则导出商务部_数据上报模板，“取消”则导出商务部一体化_数据上报模板，请选择？")){
  		url = "<%= reportURL %>/servlet/ExcecuteReport/businessdatereport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
	  }else{
		url = "<%= reportURL %>/servlet/ExcecuteReport/businessunifydatareport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
	  }
    }
    if(deptcode == "YL010104"){
    	url = "<%= reportURL %>/servlet/ExcecuteReport/TownAndCountryDataReport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
    }	
    
    DataReport(url);
}
function page_export(idx){	
	var url;
	var id = document.cform.userid.value;
	if(idx == 1){
		url = "<%= reportURL %>/servlet/ExcecuteReport/businessstockdatareport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
  	  
    }
	if(idx == 2){
		url = "<%= reportURL %>/servlet/ExcecuteReport/hosiptalstockdatareport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
	}
    if(idx == 3){
    	url = "<%= reportURL %>/servlet/ExcecuteReport/doctorsalesdatareport.sox?__folder=/ovalreport&rownum=2&employeeid="+ id;
    }	
    
    DataReport(url);
}
function page_operate(operand)
{
   if (isEmpty(cform.uploadfile.value)) {
       alert('请选择上载的文件！');
         return;
       }
   var realfilepath = eval("cform.uploadfile");
   var filename = ""
   var filetype = ""
   var pname = realfilepath.value;
   pname = pname.substring(pname.lastIndexOf("\\") + 1, pname.length);
   cform.filename.value = pname;
   var suffix = pname.substring(pname.lastIndexOf(".") + 1);
  
   
   if(suffix.toLowerCase()!="xls" && suffix.toLowerCase()!="xlsx" &&  suffix.toLowerCase()!="csv" ){
   		alert("上载的文件格式只能为：xls、xlsx、csv");
   		return;
   }
   
   //此操作需要修改浏览器的安全选项中的ActiveX初始化并执行脚本改为启动
	   //var fso = new ActiveXObject('Scripting.FileSystemObject');  
	   //var filepath = cform.uploadfile.value;
	   //var filesize = fso.GetFile(filepath).size;
	   //if(filesize>2097152){
	   		//alert("文件大小不能超过20M");
	   		//return;
	   //}
    cform.filetype.value = suffix;
	cform.encoding="multipart/form-data";
	cform.actionname.value = "upload";
	cform.target = "_self";
	cform.submit();
}





function page_getcounts(){
	var datahandler = new  DataHandler() ;
    datahandler.getResult("datacounts" ,"document.cform.tempdatacounts");
    datahandler.getResult("tabscounts" ,"document.cform.temptabscounts");
	datahandler.add_job("j_gettdruploadinfo");
	datahandler.add_function("page_checkcounts()");
	datahandler.runDataHandler();
	history.go(0);
}

function page_onload(){
	page_checkcounts();
}
 
function page_checkcounts(){
	var datacount =Number(document.cform.datacounts.value);
	var tabscount =Number(document.cform.temptabscounts.value);
		if( !<%= tabs.isEmpty()%> && datacount > 0 ){
			document.getElementById("endid").style.display = "block" ;
			document.getElementById("goingid").style.display = "none" ;
			document.getElementById("startid").style.display = "none" ;
			document.getElementById("checkajax").style.display = "none" ;
			document.getElementById("uploadfile").style.display = "none" ;
			document.getElementById("upload_button").style.display = "none" ;
			return;
		}
		
		 if (!<%= tabs.isEmpty()%> && datacount == 0 ){
			 if(<%=countlog %> < 1){
				document.getElementById("checkajax").innerHTML = "<font size=\"2\" id=\"checkajax\">&nbsp;&nbsp;&nbsp;正在加载中，请耐心等待...  </font><img src='<%= contextPath %>/images/<%= strLanguageCode %>/loadinglit.gif' >";
				setTimeout("page_checkcounts();page_getcounts()",5000); 
				document.getElementById("goingid").style.display = "none" ;
				document.getElementById("endid").style.display = "none" ;
				document.getElementById("startid").style.display = "none" ;
				document.getElementById("uploadfile").style.display = "none" ;
				document.getElementById("upload_button").style.display = "none" ;
				//document.getElementById("upload_del").style.display = "none" ;
				//document.getElementById("upload_del").style.display = "none" ;
				return;
			 }
	    } 
	    
	    if(<%= tabs.isEmpty()%> && datacount == 0){
			document.getElementById("startid").style.display = "block" ;
			document.getElementById("goingid").style.display = "none" ;
			document.getElementById("endid").style.display = "none" ;
			document.getElementById("checkajax").style.display = "none" ;
			//document.getElementById("uploadfile").style.display = "block" ;
			//document.getElementById("upload_button").style.display = "block" ;
			return;
		}
  }

</script>

</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onload="page_onload()" style="overflow: auto;">
<iframe id="reloadHandler" name="reloadHandler" style="display:none"></iframe>
<span style="display:none">
<form name="cform" method="post" action="<%=contextPath%>/Dispatcher">
<input type="hidden" name="pagename" value="p_zyldatauploadhead">
<input type="hidden" name="actionname">   
<input type="hidden" name="filename">
<input type="hidden" name="filetype">
<input type="hidden" name="counts">
<custom:hidden property="tempdatacounts"></custom:hidden>
<custom:hidden property="temptabscounts"></custom:hidden>
<custom:hidden property="deptcode"></custom:hidden>
<custom:hidden property="datacounts"></custom:hidden>
<custom:hidden property="userid" name="userinfo" scope="session"/>
</span>
<div id="div1" style="border:1px solid #44BBBB;width:100%px; overflow: auto;">
      <input type="hidden" name="languagecode" value="<%= strLanguageCode %>">
    <div class="bd" >
    <div class="sz" >
	<input type="file" name="uploadfile" width="400" class="input_sz" />&nbsp;&nbsp;&nbsp;&nbsp;<a onclick="page_operate('upload')" name="upload_button"><input type=button class="button1" value="上载" style="width:60" /></a>
	</div>
	<div class="sz" >
</div>

    <br>
	<%if(strDeptCode.equals("YL010103") ){%>
	<input type= "button" class="button1" value="商业在途库存上报模板" style="width:130"  onclick = "page_export(1)" />
    <%}else{%>
	
	<input type= "button" class="button1" value="医院库存上报模板" style="width:130"  onclick = "page_export(2)" />
	<input type= "button" class="button1" value="医生处方量上报模板" style="width:130"  onclick = "page_export(3)" />
	<%}%>
     <div id="goingid" class="RoundedCorner"  style="width:250px;height:40px;float:left;display:none;" > 
    <b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b> 
     <font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;正在处理中，请耐心等候</font><br>
    <b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b> 
    </div>   
     <div id="endid" class="RoundedCorner"  style="width:250px;height:40px;float:left;display:none;" > 
    <b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b> 
     <font size="2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;上载完毕，请校验数据无误后提交</font><br>
    <b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b> 
    </div>
	<div id="startid" class="RoundedCorner"  style="width:580px;float:left;display:none;" > 
    <b class="rtop"><b class="r1"></b><b class="r2"></b><b class="r3"></b><b class="r4"></b></b> 
    <font size="2">&nbsp;&nbsp;&nbsp;&nbsp;注:此页面只支持《医院库存上报》、《医生处方量上报》、《商业/连锁总部在途库存上报》;<br>
	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请保证上载EXCEL在500行以下，如若超过500行请分割数据分批上载！</font><br>
    <b class="rbottom"><b class="r4"></b><b class="r3"></b><b class="r2"></b><b class="r1"></b></b> 
    </div>
	<br><br>
	<div id="checkajax" style="width:250px;height:40px;float:left;" ></div> 
	<logic:iterate id="importdatalogid" collection="<%= tabs %>" indexId="idx"> 
	<%
		strTableNum = (String)((HashMap)pageContext.getAttribute("importdatalogid")).get("tablenum");
		strTableName = (String)((HashMap)pageContext.getAttribute("importdatalogid")).get("tablelable");
		if(("A01").equals(strTableNum) || countlog.intValue()>0)strTableName = "操作日志";
	%>                                  
	</logic:iterate>
    </div><br><br><br>
	<div class="title-big-b-center"><%=strTableName%></div>
</div>
</form>
<%if(("A01").equals(strTableNum) || countlog.intValue()>0){%>
<dcms:summary id="tdr.datauploadlogview">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(!("A01").equals(strTableNum) && countlog.intValue()<1){%>
<%if(("A02").equals(strTableNum)){%>
<dcms:summary id="tdr.businesspurchaseviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A03").equals(strTableNum)){%>
<dcms:summary id="tdr.abusinesssalesinvviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A04").equals(strTableNum)){%>
<dcms:summary id="tdr.bbusinesssalesinvviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A05").equals(strTableNum)){%>
<dcms:summary id="tdr.businesssellviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A06").equals(strTableNum)){%>
<dcms:summary id="tdr.pharmacypurchaseviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A07").equals(strTableNum)){%>
<dcms:summary id="tdr.hospsalesinvviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A08").equals(strTableNum)){%>
<dcms:summary id="tdr.hosppurchaseviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%if(("A09").equals(strTableNum)){%>
<dcms:summary id="tdr.doctorprescriptionviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>

</dcms:summary>
<%}%>
<%if(("A11").equals(strTableNum)){%>
<dcms:summary id="tdr.genericdrugsprescriptionviewsummary">
	<dcms:param name="userid" property="session:userinfo.userid"/>
</dcms:summary>
<%}%>
<%}%>
<script language="JavaScript">

function page_submit()
{
  counts = cform.counts.value;
  if(Number(counts)>0){
	 //if(!confirm("此期间内您已上载过数据，是否仍继续执行上载？"))return;
  }
  cform.actionname.value = "submit";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}

function page_getCounts1(){
	userid = '<%=(Integer)userinfos.get("userid")%>';
	var  datahandler = new  DataHandler();
	datahandler.add_params("userid" , userid, 'Integer');
	datahandler.getResultFromHashMap("onehash","counts","document.cform.counts");
	datahandler.add_job("j_getuploadcounts");
	datahandler.runDataHandler();
	setTimeout("page_submit();","250");
 }

function page_del()
{
  if(!confirm("重新上载将清空已上载的临时数据，是否确认？")) return;
  cform.actionname.value = "delete";
  cform.target = "_self";
  isRunning = true;
  cform.submit();
}
</script>
<iframe id="dataLoaderIframe" style="display:none;z-index:5000;overflow: auto;"></iframe>
<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
        <td>
        <center>
            <a onclick="page_getCounts1()"><input type=button class="button1" value="提交" style="width:60"></a>   
            <a onclick="page_del()" ><input type="button" class="button1" name="upload_del" value="重新上载" style="width:60"></a>     
        </center>
        </td>
    </tr>
</table>
</body>
</html>
